using System.ComponentModel.DataAnnotations;

namespace HotelRegistrationSystem.Models
{
    public class AddressModel
    {
        public int AddressId { get; set; }

        [StringLength(50, ErrorMessage = "Length must be between {2} and {1} symbols", MinimumLength = 3)]
        [Display(Name = "Region")]
        public string Region { get; set; }

        [RegularExpression("([0-9]+)", ErrorMessage = "Invalid post code")]
        [Display(Name = "Post Code")]
        public string PostCode { get; set; }

        [Required(ErrorMessage = "Required")]
        [StringLength(50, ErrorMessage = "Length must be between {2} and {1} symbols", MinimumLength = 3)]
        [Display(Name = "Country")]
        public string Country { get; set; }

        [Required(ErrorMessage = "Required")]
        [StringLength(50, ErrorMessage = "Length must be between {2} and {1} symbols", MinimumLength = 3)]
        [Display(Name = "City")]
        public string City { get; set; }

        [StringLength(50, ErrorMessage = "Length must be between {2} and {1} symbols", MinimumLength = 3)]
        [Display(Name = "Street")]
        public string Street { get; set; }

        public override string ToString()
        {
            string result = this == null ? "" : 
                string.Format("{0}, {1}.", this.City, this.Street);
            return result;
        }
    }
}